// 在主页面添加搜索功能
function submitSearch() {
    const query = document.getElementById('searchQuery').value.trim();
    const type = document.getElementById('searchType').value;

    if (query === '') {
        alert('请输入搜索关键词');
        return;
    }

    window.location.href = `search-results.jsp?query=${encodeURIComponent(query)}&type=${type}`;
}

// 回车键触发搜索
document.getElementById('searchQuery').addEventListener('keypress', function(e) {
    if (e.key === 'Enter') {
        submitSearch();
    }
});